<%--
  Created by IntelliJ IDEA.
  User: tjcu
  Date: 2019/12/3
  Time: 15:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1>用户管理</h1><br/>
<form action="/getUsers" method="post">
    <table cellspacing="0" cellpadding="4" border="1">
        <tr>
            <td>用户名：</td>
            <td><input type="text" name="name" value="${name}"> </td>
            <td><input type="submit" name="查询" > </td>
        </tr>
    </table>
</form>
<c:set var="users" value="${userPage.content}"/>
<c:if test="${ f:length(users)==0}">
    <h1>没有相关数据!</h1>
</c:if>
<c:if test="${ f:length(users)!=0}">
<table cellspacing="0" cellpadding="4" border="1">
<tr>
    <td>序号</td>
    <td>用户名</td>
    <td>用户类型</td>
    <td>用户状态</td>
    <td>最后修改时间</td>
</tr>
    <c:forEach items="${userPage.content}" var="user" varStatus="num">
        <tr>
            <td>${num.count}</td>
            <td>${user.name}</td>
            <td>${user.userType.name}</td>
            <td>${user.status==0?'冻结':'正常'}</td>
            <td><fmt:formatDate value="${user.lastModifyTime}" pattern="yyyy-MM-dd"/></td>
        </tr>
            </c:forEach>
        <tr>
            <td colspan="5">
                <c:set var="pageIndex" value="${userPage.number}"/>
                <c:set var="totalElements" value="${userPage.totalElements}"/>
                <c:set var="totalPages" value="${userPage.totalPages}"/>

                <a href="/getUsers?name=${name}">首页</a>
                <a href="/getUsers?index=${userPage.previousPageable().pageNumber==null?1:userPage.previousPageable().pageNumber+1}&name=${name}">上一页</a>
<c:forEach begin="1" end="${totalPages}" var="i">
    <c:if test="${i==pageIndex}">
        <a href="/getUsers?index=${i}&name=${name}">${i}</a>
    </c:if>
    <c:if test="${i!=pageIndex}">
        <a href="/getUsers?index=${i}&name=${name}">${i}</a>
    </c:if>
</c:forEach>
    <a href="/getUsers?index=${userPage.nextPageable().pageNumber==null?totalPages:userPage.nextPageable().pageNumber+1}&name=${name}">下一页</a>
                <a href="/getUsers?index=${totalPages}&name=${name}"> 尾页</a>
                共${totalElements}条  共${totalPages} 页 ${pageIndex+1}/${totalPages}
            </td>
        </tr>
</table>
</c:if>
</body>
</html>
